import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceInfoVO, DeviceInfoForm, DeviceInfoQuery } from '@/api/device/deviceInfo/types';

/**
 * 查询人脸设备管理列表
 * @param query
 * @returns {*}
 */

export const listDeviceInfo = (query?: DeviceInfoQuery): AxiosPromise<DeviceInfoVO[]> => {
  return request({
    url: '/device/deviceInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询人脸设备管理详细
 * @param id
 */
export const getDeviceInfo = (id: string | number): AxiosPromise<DeviceInfoVO> => {
  return request({
    url: '/device/deviceInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增人脸设备管理
 * @param data
 */
export const addDeviceInfo = (data: DeviceInfoForm) => {
  return request({
    url: '/device/deviceInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改人脸设备管理
 * @param data
 */
export const updateDeviceInfo = (data: DeviceInfoForm) => {
  return request({
    url: '/device/deviceInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除人脸设备管理
 * @param id
 */
export const delDeviceInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/device/deviceInfo/' + id,
    method: 'delete'
  });
};

/**
 * 同步鸿图设备列表
 * @param query
 * @returns {*}
 */

export const syncAiotDeviceList = (query?: DeviceInfoQuery): AxiosPromise<any> => {
  return request({
    url: '/device/deviceInfo/syncAiotDeviceList',
    method: 'get',
    params: query
  });
};

/**
 * 同步鸿图用户
 * @param query
 * @returns {*}
 */

export const syncAiotUserInfo = (): AxiosPromise<any> => {
  return request({
    url: '/device/deviceInfo/syncAiotUserInfo',
    method: 'get'
  });
};

/**
 * 下发人员信息至面板机
 * @param query
 * @returns {*}
 */

export const batchAddPerson = (data: Array<any>): AxiosPromise<any> => {
  return request({
    url: '/device/mqtt/batchAddPerson',
    method: 'post',
    data
  });
};

/**
 * 清空设备白名单
 * @param query
 * @returns {*}
 */

export const deletePersonList = (data: Array<any>): AxiosPromise<any> => {
  return request({
    url: '/device/mqtt/deletePersonList',
    method: 'post',
    data
  });
};

/**
 * 重启面板机
 * @param query
 * @returns {*}
 */

export const restartRequest = (data: Array<any>): AxiosPromise<any> => {
  return request({
    url: '/device/mqtt/restartRequest',
    method: 'post',
    data
  });
};

/**
 * 添加通行策略
 * @param query
 * @returns {*}
 */

export const addStrategy = (data: Array<any>): AxiosPromise<any> => {
  return request({
    url: '/device/mqtt/addStrategy',
    method: 'post',
    data
  });
};
